﻿Menu = Class.create();

Menu.prototype = Object.extend(new Common(), {
    initialize: function () {
        this.initCommonProperty();
    },

    init: function () {
        //页面默认加载数据取得
        this.getMenuList(1);
    },
    //取得sub_menu
    getMenuList: function (parent_id) {
        var data = {};
        data.parent_id = parent_id;
        this.sendAjaxByModel("/Control/GetMenuList", data, this.getMenuListCallback.bind(this));
    },
    //CallBack处理
    getMenuListCallback: function (response) {
        var json = this.jsonParse(response);
        $j("#menu_ul").empty();

        var strSubMenu = "";

        if (json.length > 0) {
            for (var i = 0; i < json.length; i++) {
                strSubMenu += "<li id=\"sub_menu_" + json[i].menu_id + "\"><a>" + json[i].menu_name + "</a></li>";
            }
            $j("#menu_ul").append(strSubMenu);
        }
        //sub_menu绑定事件
        for (var i = 0; i < json.length; i++) {
            Event.observe($("sub_menu_" + json[i].menu_id), 'click', this.onClick_MenuInfo.bind(this, json[i]));
        }

        this.initMenu();
    },
    //点击sub_mune导航触发事件
    onClick_MenuInfo: function (json) {
        if (json == undefined || json == null) {
            return;
        }
        mainFormIns.cmnTabIns.addTab(json);
    },

    initMenu: function () {
        var menu_li = $j("#menu_ul>li");

        var spead = 100;

        menu_li.hover(function () {
            $j(this).find("a").stop().animate({
                'paddingLeft': "40"
            }, spead);
        }, function () {
            $j(this).find("a").stop().animate({
                'paddingLeft': "25"
            }, spead);
        });


    }
});